<p>Initial total late days allowed: {{ late_days.getDefaultLateDays() }}</p>
{% if late_days.getLateDaysUpdates()|length != 0 %}
    <p>Late day history:</p>
    <ul id="late-day-history">
        {% set cumulative_days = late_days.getDefaultLateDays() %}
        {% for late_days_update in late_days.getLateDaysUpdates() %}
            {% set diff = late_days_update.allowed_late_days - cumulative_days %}
            {% if diff >= 0 %}
                <li>{{ late_days_update.since_timestamp|date('m/d/Y') }}: Earned {{ diff }} late day(s)</li>
            {% else %}
                <li>{{ late_days_ulidate.since_timestamp|date('m/d/Y') }}: Lost {{ -diff }} late day(s)</p>
            {% endif %}
            {% set cumulative_days = late_days_update.allowed_late_days %}
        {% endfor %}
    </ul>
{% endif %}

<p>Total late days used: {{ late_days.getLateDaysUsed() }}</p>
<p>Total late days remaining for future assignments: {{ late_days.getLateDaysRemaining() }}</p>
{# This table is a data table #}
<table id="late-day-table" class="mobile-table">
    <thead>
        <tr>
            <th>Assignment name</th>
            <th>Due date</th>
            <th>Maximum number of late days allowed for this assignment</th>
            <th>Assignment submitted # of days after deadline</th>
            <th>Student granted # of days extension for this assignment</th>
            <th>Status</th>
            {% if grade_inquiry_enabled %}
                <th>Grade Inquiries</th>
            {% endif %}
            <th>Late days charged for this assignment</th>
        </tr>
    </thead>
    <tbody>
    {% for late_day_info in late_days.getLateDayInfo() %}
        {% set graded_gradeable = late_day_info.getGradedGradeable() %}
        {% set gradeable = graded_gradeable.getGradeable() %}
        {% set class = "" %}
        {% set id = "" %}
        {% if highlight_gradeable == gradeable.getId() %}
            {% set class = "blue-background" %}
            {% set id = "curr-status" %}
        {% endif %}
        <tr>
            <td class="align-left {{ class }}">{{ gradeable.getTitle() }}</td>
            <td class="{{ class }}">{{ gradeable.getSubmissionDueDate()|date('m/d/Y') }}</td>
            <td class="{{ class }}">{{ late_day_info.getAssignmentAllowedLateDays() }}</td>
            <td class="{{ class }}">{{ (late_day_info.getDaysLate() != 0) ? late_day_info.getDaysLate() : "N/A" }}</td>
            <td class="{{ class }}">{{ (late_day_info.getLateDayException() != 0) ? late_day_info.getLateDayException() : "N/A" }}</td>
            <td class="{{ class }}" id="{{ id }}">{{ late_day_info.getStatusMessage() }}</td>
            {% if grade_inquiry_enabled %}
                <td class="{{ class }}" id="{{ id }}">{{ gradeable.isRegradeAllowed() ? late_day_info.getGradeInquiryCount() : "N/A" }}</td>
            {% endif %}
            <td class="{{ class }}">{{ (late_day_info.getLateDaysCharged() != 0 ) ? late_day_info.getLateDaysCharged() : "N/A" }}</td>
        </tr>
    {% endfor %}
    </tbody>
</table>
